package com.fantabest.frontend.client.mvc;

import com.extjs.gxt.ui.client.event.EventType;
import com.extjs.gxt.ui.client.mvc.AppEvent;
import com.extjs.gxt.ui.client.mvc.Controller;
import com.fantabest.common.client.AppEvents;

public class AppController extends Controller {

	private AppView appView;
	
	public AppController() {
		super();
		registerEventTypes(AppEvents.Init);
		registerEventTypes(AppEvents.Login);
		registerEventTypes(AppEvents.GoToLogin);		
		registerEventTypes(AppEvents.Logoff);
		registerEventTypes(AppEvents.Error);
		registerEventTypes(AppEvents.MenuMarket);
	}

	@Override
	public void handleEvent(AppEvent event) {
	    EventType type = event.getType();
	    if (type == AppEvents.Init) {
	    	forwardToView(appView, event);
	    } else if (type == AppEvents.Login) {
	    	forwardToView(appView, event);
	    } else if (type == AppEvents.GoToLogin) {
	    	forwardToView(appView, event);
	    } else if (type == AppEvents.Logoff) {
	    	forwardToView(appView, event);
	    } else if (type == AppEvents.MenuMarket) {
	    	forwardToView(appView, event);
	    } else if (type == AppEvents.Error) {
	    }		
	}
	
	@Override
	protected void initialize() {
		super.initialize();
		appView = new AppView(this);
	}

}
